<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<%@include file="/WEB-INF/taglibs/common/taglibs.jsp"%>
<head>
<title><spring:message code="sp.faq.question.title" /></title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="stylesheet" href="<c:url value="/css/styles.css"/>" />
<script src="<c:url value="/javascripts/common.js"/>"></script>

</head>

<body>
<%@include file="../top_menu.jsp"%>
<table width="100%">
	<tr>
		<td><c:import url="/WEB-INF/jsp/serviceprovider/faq/faq_menu.jsp" />
		</td>
	</tr>
</table>

<div class="contentArea">
<table border=0 cellpadding=0 cellspacing=0 width=70% align="center">
	<tr>
		<td valign="top"></td>
		<td valign="top">
		<table border="0" cellpadding="5" cellspacing="5" width="100%" align="center">

			<tr>
				<td colspan="2">
				<form:form commandName="newQuestion" method="post" onsubmit="return validateForm()">
					<table width=70% class="formTable" cellpadding="5" cellspacing="5">
						<tr>
							<td colspan="2" align="center"><h3><spring:message code="sp.faq.question.label.submitquestion" />.</h3></td>
						</tr>
										 
						<tr>
							<td><spring:message code="sp.faq.question.label.email" /><font color=red>*</font></td>
							<td><form:input path="email" size="70" maxlength="45" />
								<form:hidden path="userId" />
							</td>
						</tr>
						
						<tr>
							<td><spring:message code="sp.faq.question.label.firstname" /><font color=red>*</font></td>
							<td><form:input path="firstName" size="70" maxlength="45" />
							<div class="errors"><form:errors path="firstName" /></div>
							</td>
						</tr>
						
						<tr>
							<td><spring:message code="sp.faq.question.label.lastname" /><font color=red>*</font></td>
							<td><form:input path="lastName" size="70" maxlength="45" />
							<div class="errors"><form:errors path="lastName" /></div>
							</td>
						</tr>												
						
						<tr>
							<td><spring:message code="sp.faq.question.label.subject" /><font color=red>*</font></td>
							<td>
								<form:select path="category.id" cssStyle="width:360px">
								<c:forEach items="${listCategories}" var="cat" varStatus="i">
									<form:option value="${cat.id}">${cat.name}</form:option>
								</c:forEach>								
								</form:select>
							</td>
						</tr>
						
						<tr>
							<td colspan="2">
							<spring:message code="sp.faq.question.label.securityqeustiontext" />.
							</td>
						</tr>
												
						<tr>
							<td><spring:message code="sp.faq.question.label.question" /><font color=red>*</font></td>
							<td><form:textarea path="question" cols="40" rows="7" />
							<div class="errors"><form:errors path="question" /></div>
							</td>
						</tr>												

						<tr>
							<td><spring:message code="sp.faq.question.label.order" /> #<font color=red>*</font></td>
							<td><form:input path="orderNumber" size="70" maxlength="45" />
							<div class="errors"><form:errors path="orderNumber" /></div>
							</td>
						</tr>
						
						<tr>
							<td colspan="2">
							<spring:message code="sp.faq.question.label.ordernumbertext" />.
							</td>
						</tr>

						<tr>
							<td><spring:message code="sp.faq.question.label.confidentialquestion" /></td>
							<td><form:checkbox path="confidential" /></td>
						</tr>
														
						<tr>
							<td><spring:message code="sp.faq.question.label.tag" /></td>
							<td><form:input path="tag" size="70" maxlength="255" /></td>
						</tr>
																		
						<tr>
							<td colspan="2">&nbsp;</td>
						</tr>

						<tr>
							<td colspan="2" align="center"><input type="submit" class='ui-button ui-state-default ui-corner-all'
								id="createPayee" value="<spring:message code="sp.faq.question.button.submit" />..." /> <input type="button" class='ui-button ui-state-default ui-corner-all'
								value="<spring:message code="sp.faq.question.button.cancel" />" onclick="location.href='faq_home.htm'" /></td>
						</tr>
					</table>
				</form:form></td>
			</tr>
		</table>
		</td>
	</tr>

	<script language="javascript">
		function validateForm() {
			var isValid = true;
			var emailField = document.getElementById("email");
			var firstNameField = document.getElementById("firstName");
			var lastNameField = document.getElementById("lastName");
			var subjectField = document.getElementById("category.id");
			var questionField = document.getElementById("question");
			var orderField = document.getElementById("orderNumber");
			var tagField = document.getElementById("tag");
			
		   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
			
					
			isValid = validate_required(emailField, 'Please enter email');
			
			if (isValid) {
				isValid = validate_length(emailField, 'Email', 45);
			}
			
			if (isValid) {
			   if(reg.test(emailField.value) == false) {
			      alert('Invalid Email Address');
			      isValid = false;
			   }			
			}
			
			if (isValid) {
				isValid = validate_required(firstNameField,'Please enter first name');
			}
			
			if (isValid) {
				isValid = validate_length(firstNameField, 'First Name', 45);
			}
			
			if (isValid) {
				isValid = validate_required(lastNameField,'Please enter last name');
			}
			
			if (isValid) {
				isValid = validate_length(lastNameField, 'Last Name', 45);
			}			
			
			if (isValid) {
				isValid = validate_required(questionField,'Please enter question');
			}
			
			if (isValid) {
				isValid = validate_length(questionField, 'Question', 3000);
			}			
			
			if (isValid) {
				isValid = validate_required(orderField,'Please enter order number');
			}
			
			if (isValid) {
				isValid = validate_length(orderField, 'Order Number', 45);
			}			
			
			if (isValid) {
				isValid = validate_length(tagField, 'Tag', 255);
			}			
			
			return isValid;
		}
	</script>

</table>
</div>

<%@include file="/WEB-INF/jsp/include/footer.jsp"%>
</body>
</html>